﻿//-----------------------------------------------------------------------
// <copyright file="Atom.cs" company="tuliprules.org">
//     Copyright (c) 2011 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the Atom class.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Rules.Models.Rif.Core
{
    using System;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents an atom formula, positional or with named arguments.
    /// </summary>
    [Serializable]
    [DesignerCategory(@"code")]
    [XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2007/rif#")]
    [XmlRoot(Namespace = "http://www.w3.org/2007/rif#", IsNullable = false)]
    public class Atom : Irimeta, IRifCoreElement
    {
        /// <summary>
        /// The op field.
        /// </summary>
        [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
            Justification = "Reviewed. Suppression is OK here."), EditorBrowsable(EditorBrowsableState.Never)]
        private Op opField;

        /// <summary>
        /// The args field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)] private ArgsUnitermType argsField;

        /// <summary>
        /// Initializes a new instance of the <see cref="Atom"/> class. 
        /// </summary>
        public Atom()
        {
            this.opField = new Op();
        }

        /// <summary>
        /// Gets or sets the Atom/Expr role for predicates/functions as operations.
        /// </summary>
        [XmlElement("op", Order = 0)]
        public Op Op
        {
            get { return this.opField; }
            set { this.opField = value; }
        }

        /// <summary>
        /// Gets or sets an Atom/Expr positional arguments role, with ordered="yes" 
        /// attribute, containing n TERMs.
        /// </summary>
        [XmlElement("args", Order = 1)]
        public ArgsUnitermType Args
        {
            get { return this.argsField; }
            set { this.argsField = value; }
        }
    }
}